package org.one.stone.soup.grfxML.applet;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Point;

import javax.swing.JApplet;

import org.one.stone.soup.browser.Browser;
import org.one.stone.soup.grfx.ImageFactory;
import org.one.stone.soup.grfxML.GrfxMLController;
import org.one.stone.soup.grfxML.GrfxMLEngine;
import org.one.stone.soup.grfxML.GrfxMLView;
import org.one.stone.soup.grfxML.ui.GrfxMLJComponent;
import org.one.stone.soup.xml.XmlDocument;

public class GiraffeApplet extends JApplet implements GrfxMLController{
	
	private GrfxMLJComponent giraffe;
	private GrfxMLEngine engine;
	public GiraffeApplet()
	{		
		ImageFactory.root = GiraffeApplet.class;

		Browser.initialize(true,"grfxml");
		String alias = "Giraffe Applet";
		
		XmlDocument settings = new XmlDocument("settings");
		int width = this.getWidth();
		int height = this.getHeight();
		
		engine = new GrfxMLEngine(this,alias,settings);
		giraffe = new GrfxMLJComponent(engine,this,width,height);
		engine.setView(giraffe);
		
		getContentPane().add(giraffe,BorderLayout.CENTER);
		
		String url = getParameter("url");
		if(url==null)
		{
			url = "jar://resources/giraffe/modeler/modeler.grfxml";
		}
		engine.getAPI().load(url);
	}

	public boolean choose(String[] text) {
		// TODO Auto-generated method stub
		return false;
	}

	public Component getComponent() {
		return giraffe;
	}

	public Point getMouseOffset() {
		return new Point(0,0);
	}

	public String getValue(String name) {
		// TODO Auto-generated method stub
		return null;
	}

	public GrfxMLView getView() {
		return giraffe;
	}

	public void sendCommand(String command) {
		// TODO Auto-generated method stub
		
	}

	public void setReady(GrfxMLEngine engine) {
		// TODO Auto-generated method stub
		
	}

	public void setTitle(String title) {
		// TODO Auto-generated method stub
		
	}

	public void setWaiting(boolean state) {
		// TODO Auto-generated method stub
		
	}

	public void showConsole(boolean state) {
		// TODO Auto-generated method stub
		
	}

	public void showLoadError(Exception e, Object resourceName) {
		// TODO Auto-generated method stub
		
	}

	public void showWebPage(String url) {
		// TODO Auto-generated method stub
		
	}

	public String userGetFile(String label, String[] masks) {
		// TODO Auto-generated method stub
		return null;
	}

}
